<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php 
include_once("../common.php");
?>

<?php //set up db
	$DB = DBConnect();
	$query = "  
	CREATE TABLE `client` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `type` tinyint(4) DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `contact` varchar(250) NOT NULL,
  `fund` double(4,0) DEFAULT NULL,
  `demand` tinyint(4) DEFAULT NULL,
  `charact` tinyint(4) DEFAULT NULL,
  `devspeed` tinyint(4) DEFAULT NULL,
  `next_devtime` datetime DEFAULT NULL,
  `deal_time` datetime DEFAULT NULL,
  `deal_money` double DEFAULT NULL,
  `addict_dev` tinyint(1) DEFAULT NULL,
  `suppose_saler` text,
  `othersalers` text,
  `product` text,
  `remark` text,
  `submit_time` datetime DEFAULT NULL,
  `createid` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;
	";

	$resutl = mysql_query($query,$DB);
	if(!$resutl){ 
		echo mysql_error();
		//die("创建失败");
	}

	$query = "
	CREATE TABLE `client_saler_rel` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `salerid` int(11) NOT NULL,
  `clientid` int(11) NOT NULL,
  `starttime` datetime NOT NULL,
  `endtime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `state` enum('closed','active') NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8;
";
	$resutl = mysql_query($query,$DB);
	if(!$resutl){ 
		echo mysql_error();
		//die("创建失败");
	}

	$query = "
	CREATE TABLE `saler` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(120) NOT NULL,
  `password` varchar(1024) NOT NULL,
  `state` enum('enabled','disabled') NOT NULL DEFAULT 'disabled',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
	";
	
	$resutl = mysql_query($query,$DB);
	if(!$resutl){ 
		echo mysql_error();
		//die("创建失败");
	}
	
	$query ="
	CREATE TABLE `todolist` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `timetodo` datetime DEFAULT NULL,
  `content` text,
  `salerid` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
";

	$resutl = mysql_query($query,$DB);
	if(!$resutl){ 
		echo mysql_error();
		//die("创建失败");
	}
	
	echo "创建成功";
	echo "<a href='index.php'>回主页</a>";

?>
</body>
</html>